<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->

<script>

  Polymer.BehaviorA = {

    properties: {

      label: {
        type: String,
        observer: '_labelChanged'
      },

      hasOptionsA: {
        readOnly: true,
        notify: true
      },

      overridableProperty: {
        value: false
      },

      overridablePropertyB: {
        value: false
      },

      hasBehaviorA: {
        value: true
      }
    },

    _simpleProperty: 'A',

    hostAttributes: {
      behavior: 'A',
      user: 'A'
    },

    listeners: {
      change: '_changeHandler'
    },

    ready: function() {
      this.__readyA = true;
    },

    _labelChanged: function(label) {
      this.__label = label;
    },

    _changeHandler: function(e) {
      this.__change = e.detail.value;
    },

    _toOverride: function() {
    }

  };

</script>

<script>

  Polymer.BehaviorB = {

    properties: {

      disabled: {
        type: Boolean,
        value: false,
        observer: '_disabledChanged'
      },

      hasOptionsB: {
        readOnly: true,
        notify: true
      },

      hasBehaviorB: {
        value: true
      },

      overridablePropertyB: {
        value: true
      },

    },

    hostAttributes: {
      behavior: 'B',
      user: 'B'
    },

    _simpleProperty: 'B',

    _disabledChanged: function(disabled) {
      this.__disabled = disabled
    },

    ready: function() {
      this.__readyB = true;
    },

    _toOverride: function() {}

  };

</script>

<dom-module id="single-behavior">

  <script>

    Polymer({

      behaviors: [
        Polymer.BehaviorA
      ]

    });

  </script>

</dom-module>

<dom-module id="multi-behaviors">

  <script>

    Polymer({

      behaviors: [
        Polymer.BehaviorA,
        null,
        Polymer.BehaviorB
      ],

      properties: {

        foo: {
          type: String,
          reflectToAttribute: true,
          readOnly: true,
          observer: '_fooChanged'
        },

        overridableProperty: {
          value: true
        }

      },

      _fooChanged: function(foo) {
        this.__foo = foo;
      },

     _toOverride: Polymer._toOverride

    });

  </script>

</dom-module>

<script>

  Polymer.BehaviorC = {

    properties: {

      hasBehaviorC: {
        value: true
      }

    },

    _simpleProperty: 'C'

  };

  Polymer.BehaviorD = {

    properties: {

      hasBehaviorD: {
        value: true
      }

    },

    _simpleProperty: 'D'

  };

</script>

<dom-module id="nested-behaviors">

  <script>

    Polymer({

      behaviors: [
        [[Polymer.BehaviorC, Polymer.BehaviorB], Polymer.BehaviorA],
        Polymer.BehaviorD
      ]

    });

  </script>

</dom-module>